package com.qingkai.onlineshop.app

import androidx.compose.runtime.Composable
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.toRoute
import com.qingkai.onlineshop.presentation.cart.CartScreen
import com.qingkai.onlineshop.presentation.dashboard.DashboardScreen
import com.qingkai.onlineshop.presentation.detail.DetailScreen
import com.qingkai.onlineshop.presentation.product.ProductScreen
import com.qingkai.onlineshop.presentation.splash.SplashScreen

/**
 *作者：created by 89270 on 2025/6/3 18:43
 *描述：
 */
@Composable
fun APP() {
    val navController = rememberNavController()
    NavHost(navController = navController, startDestination = Route.Splash) {
        composable<Route.Splash> {
            SplashScreen {
                navController.navigate(it) {
                    popUpTo<Route.Splash> {
                        inclusive = true
                    }
                    launchSingleTop = true
                }

            }
        }
        composable<Route.Dashboard> { DashboardScreen { navController.navigate(it) } }
        composable<Route.Product> {
            ProductScreen(
                param = it.toRoute(),
                upPress = { navController.navigateUp() },
                navigateToRoute = { navController.navigate(it) })
        }
        composable<Route.Detail> {
            DetailScreen(
                param = it.toRoute(),
                upPress = { navController.navigateUp() },
                navigateToRoute = { navController.navigate(it) } )
        }
        composable<Route.Cart> {
            CartScreen(upPress = { navController.navigateUp() })
        }
    }
}